#pragma once

#include"IRenderableObject.h"
#include"pgMaterial.h"
#include"pgMesh.h"


/**
The default renderable object.
Currently support for Wavefront OBJ and Autodesk FBX is planned.
OBJ will be discarded once FBX fully functions. Also plannings are that
PaleGem will use its own material file format hence the object consists of 
geometry and a material.
@see IRenderableObject
*/
class PALEGEM_API pgRenderableObject : public IRenderableObject
{
public:

	pgRenderableObject();
	pgRenderableObject(pgRenderableObject *pCopy);
	~pgRenderableObject();

	bool Load(const char* szFilePath);

	bool Load() {return Load(".\\Data\\Meshes\\PaleGemEngine\\defaultCube.obj");}

	/**
	@see IRenderableObject::Render()
	*/
	void Render();

	 void PreRender();

	 void PostRender();

	  pgMat44 GetWorldTransformMatrix() {return m_worldTransformMatrix;}
	  void SetWorldTransformMatrix(pgMat44 mat) {m_worldTransformMatrix = mat;}


	void SetMesh(pgMesh *pM) {m_pMesh = pM;}

private:

	/**
	Loads an OBJ style mesh.
	@param szFilePath Path to the *.obj file
	@returns true on success
	*/
	bool LoadOBJ(const char* szFilePath);

	/**
	Load a material from a file
	@param szFilePath Path tp the *.mtl file
	@return true on success
	*/
	bool LoadOBJMaterial(const char* szFilePath);

	/**
	Load a FBX file.
	@param szFilePath Path to the *.fbx file
	@returns true on succes
	*/
	bool LoadFBX(const char* szFilePath);

	/** The geometry */
	pgMesh *m_pMesh;
	/** The material */
	pgMaterial *m_pMaterial;

	pgMat44 m_worldTransformMatrix;

	ID3D11Buffer *m_pConstantBuffer;
};